import { createBrowserRouter } from 'react-router-dom';
import { lazy } from 'react';
import LazyLoading from './LazyLoading';
import Login from '@/pages/Login/Login';
import NotFound from '@/pages/404';
import AdminLogin from '@/adminPage/Login/Login';
import AdminAuth from './AdminAuth';
const router = createBrowserRouter(
  [
    {
      path: '/',
      element: LazyLoading(lazy(() => import('@/pages/Home/Home'))),
      children: [
        // 首页
        {
          path: '/',
          element: LazyLoading(lazy(() => import('@/pages/HomeContent/HomeContent'))),
        },
        // 课堂详情
        {
          path: '/classroom/:id',
          element: LazyLoading(lazy(() => import('@/pages/ClassroomDetail/ClassroomDetail'))),
        },
        // 节日、节气、生肖、星座
        {
          path: '/Classify/:type',
          element: LazyLoading(lazy(() => import('@/pages/Classify/Classify'))),
        },
        // 个人中心
        {
          path: '/IndividualCenter',
          element: LazyLoading(lazy(() => import('@/pages/IndividualCenter/IndividualCenter'))),
        },
      ],
    },
    {
      path: '/admin',
      element: <AdminAuth>{LazyLoading(lazy(() => import('@/adminPage/Home/Home')))}</AdminAuth>,
      children: [
        {
          path: 'home',
          element: LazyLoading(lazy(() => import('@/adminPage/HomeContent/HomeContent'))),
        },
        {
          path: 'user',
          element: LazyLoading(lazy(() => import('@/adminPage/User/User'))),
        },
        {
          path: 'course',
          element: LazyLoading(lazy(() => import('@/adminPage/Course/Course'))),
        },
        {
          path: 'review',
          element: LazyLoading(lazy(() => import('@/adminPage/Review/Review'))),
        },
      ],
    },
    {
      path: '/admin/login',
      element: (
        <AdminAuth>
          <AdminLogin />
        </AdminAuth>
      ),
    },
    {
      path: '/login',
      element: <Login />,
    },
    {
      path: '*',
      element: <NotFound />,
    },
  ],
  {
    future: {
      v7_relativeSplatPath: true,
    },
  }
);

export default router;
